<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设置上课时段')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-times-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">上课时间：</label>
            <div class="col-sm-4">
                <input  id="time1" name="time1" class="form-control" th:value="${time1}" type="text" required maxlength="2"/>
                <input  id="tempDate" name="tempDate" th:value="${tempDate}" class="form-control" type="hidden"/>
            </div>
            <div class="col-sm-1">：</div>
            <div class="col-sm-4">
                <input  id="time2" name="time2" class="form-control" th:value="${time2}" type="text" required maxlength="2"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">下课时间：</label>
            <div class="col-sm-4">
                <input  id="time3" name="time3" class="form-control" th:value="${time3}" type="text" required maxlength="2"/>
            </div>
            <div class="col-sm-1">：</div>
            <div class="col-sm-4">
               <input  id="time4" name="time4" class="form-control" th:value="${time4}" type="text" required maxlength="2"/>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />

<script>

    $("#form-times-add").validate({
        onkeyup: false,
        rules:{
            time1: {
                required: true,    //要求输入不能为空
                number: true,
                max: 24
            },
            time2: {
                required: true,    //要求输入不能为空
                number: true,
                max: 60
            },
            time3: {
                required: true,    //要求输入不能为空
                number: true,
                max: 24
            },
            time4: {
                required: true,    //要求输入不能为空
                number: true,
                max: 60
            }
        },
        messages: {
            "time1": {
                required: "不能为空！",
                number: "请输入正确数字！"
            },
            "time2": {
                required: "不能为空！",
                number: "请输入正确数字！"
            },
            "time3": {
                required: "不能为空！",
                number: "请输入正确数字！"
            },
            "time4": {
                required: "不能为空！",
                number: "请输入正确数字！"
            }
        },
        focusCleanup: true
    });


    function submitHandler() {
        if ($.validate.form()) {
            // $.modal.alertWarning("请选择");
            var time1 = $("#time1").val();
            var time2 = $("#time2").val();
            var time3 = $("#time3").val();
            var time4 = $("#time4").val();
            var tempDate = $("#tempDate").val();
            parent.chooseTimes(tempDate, time1, time2, time3, time4);
            $.modal.close();
        }
    }
</script>
</body>
</html>